package com.example.demo.common.r2dbc;

import org.reactivestreams.Publisher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

public interface BaseService<T, ID> {

    <S extends T> Mono<S> save(S entity);

    <S extends T> Flux<S> saveAll(Iterable<S> entitys);

    <S extends T> Flux<S> saveAll(Publisher<S> entitys);

    Mono<T> findById(ID id);

    Mono<T> findById(Publisher<ID> id);

    Mono<Boolean> existsById(ID id);

    Mono<Boolean> existsById(Publisher<ID> id);

    Flux<T> findAll();

    Flux<T> findAllById(Iterable<ID> ids);

    Flux<T> findAllById(Publisher<ID> ids);

    Mono<Long> count();

    Mono<Void> deleteById(ID id);

    Mono<Void> deleteById(Publisher<ID> id);

    Mono<Void> delete(T entity);

    Mono<Void> deleteAll(Iterable<? extends T> entitys);

    Mono<Void> deleteAll(Publisher<? extends T> entitys);

    Mono<Void> deleteAll();

    Mono<Page<T>> findAllPage(Pageable pageable);
}
